import java.util.*; 
import java.io.*;
import edu.vanderbilt.isis.sm.*; 
import edu.vanderbilt.isis.sm.Pseudostate.Kind; 
import edu.vanderbilt.isis.sm.properties.*; 
import com.martiansoftware.jsap.*;
public class TopLevelAnchorCell { 
	public StateMachine sm = new StateMachine(); 
	public Interpreter sim; 
	public TopLevelAnchorCell() { }
	public static void main(String[] args) throws Exception {
		TopLevelAnchorCell example = new TopLevelAnchorCell();
		FlaggedOption semantics = new FlaggedOption("semantics")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("SF")
	        .setRequired(false)
	        .setShortFlag('s')
	        .setLongFlag("semantics");
		FlaggedOption dataProviderArg = new FlaggedOption("dataProvider")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("CommandLine")
	        .setRequired(false)
	        .setShortFlag('d')
	        .setLongFlag("dataProvider");
		FlaggedOption maxSteps = new FlaggedOption("maxSteps")
			.setStringParser(JSAP.INTEGER_PARSER)
	        .setDefault("10")
	        .setRequired(false)
	        .setShortFlag(JSAP.NO_SHORTFLAG)
	        .setLongFlag("maxSteps");
		FlaggedOption csvFile = new FlaggedOption("csvFilePath")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("")
	        .setRequired(false)
	        .setShortFlag('c')
	        .setLongFlag("csvFile");
		Switch checkOutputSw = new Switch("checkOutput")
	        .setShortFlag(JSAP.NO_SHORTFLAG)
	        .setLongFlag("checkOutput");
		FlaggedOption looperArg = new FlaggedOption("looper")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("Default")
	        .setRequired(false)
	        .setShortFlag('l')
	        .setLongFlag("looper");
		Switch checkPropertiesSw = new Switch("checkProperties").setShortFlag(
				JSAP.NO_SHORTFLAG).setLongFlag("checkProperties");

		JSAP jsap = new JSAP();
		jsap.registerParameter(semantics);
		jsap.registerParameter(dataProviderArg);
		jsap.registerParameter(csvFile);
		jsap.registerParameter(checkOutputSw);
		jsap.registerParameter(maxSteps);
		jsap.registerParameter(looperArg);
		jsap.registerParameter(checkPropertiesSw);
		JSAPResult config = jsap.parse(args);

		IDataProvider dataProvider = new CommandLineDataProvider();
		IDataPrinter dataPrinter = null;
		ILooper looper = new DefaultLooper();
		List<Pattern> patterns = new ArrayList<Pattern>();

		if (config.getString("dataProvider").toUpperCase().equals("CSV")) {
			String fileName = config.getString("csvFilePath");
			boolean checkOutput = config.getBoolean("checkOutput");
			CSVDataProvider csvDP = new CSVDataProvider(fileName, checkOutput);
			dataProvider = csvDP;
			if (checkOutput){
				dataPrinter = csvDP;
			}
		}
		if (config.getString("dataProvider").toUpperCase().equals("SYMBOLIC")) {
			int steps = config.getInt("maxSteps");
			SymbolicDataProvider sDP = new SymbolicDataProvider(steps);
			dataProvider = sDP;
		}

		if (config.getString("looper").toUpperCase().equals("NONDETERMINISTIC")){
			looper = new NondeterministicLooper();
		}

		if (config.getBoolean("checkProperties")) {
			patterns = example.makeProperties(example.r1.AnchorCell3);
		}

		IDataReader dataReader = new AnchorCellReader(example.r1.AnchorCell3, dataProvider, dataPrinter);
		if (config.getString("semantics").toUpperCase().equals("UML")) {
			example.sim = new UMLInterpreter(example.sm, dataReader, looper);
		}
		else if (config.getString("semantics").toUpperCase().equals("RHAPSODY")) {
			example.sim = new RhapsodyInterpreter(example.sm, dataReader, looper);
		}
		else {
			example.sim = new StateflowInterpreter(example.sm, dataReader, looper, patterns);
		}
		example.sim.getLooper().setInterpreter(example.sim);
		example.initializeTransitions();
		example.DoSim();
}
	public void DoSim() { 
		this.sim.initialize(); 
		this.sim.dataAndEventLoop();
	} 
	public List<Pattern> makeProperties(REGION_T.STATE_T s) { 
		ArrayList<Pattern> patterns = new ArrayList<Pattern>(); 
		return patterns; 
	}
	public class REGION_T extends Region { 
	public REGION_T(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p3 = new Pseudostate(this, Kind.INITIAL);
	public class STATE_T extends State {
	public int ISd0 ;
public int high  = 4 ;
public int ISd2 ;
public int ISd1 ;
public int ISd3 ;
public int ko  = 0 ;
public int formed  = 1 ;
public int ablated  = 0 ;
public int lin3 ;
public int low  = 1 ;
public int low1  = 2 ;
public int med  = 3 ;
public int a_ac ;
public int a_lin15 ;
public int off  = 0 ;
public int rf  = 3 ;
public int lin15 ;
public int on  = 17 ;
public int wt  = 1 ;
	public void setData( int val_0,  int val_1 ) {
		this.a_ac = val_0;
		this.a_lin15 = val_1;
	}
		public STATE_T( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR18 extends Region { 
	public RegionR18(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p26 = new Pseudostate(this, Kind.INITIAL);
	public class StateAC16 extends State {
			public StateAC16( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR17 extends Region { 
	public RegionR17(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p2 = new Pseudostate(this, Kind.INITIAL);
	public class StateACInit17 extends State {
			public StateACInit17( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	}
	public StateACInit17 ACInit10 = new StateACInit17("ACInit", this, false );
	public class StateLin3Off18 extends State {
			public StateLin3Off18( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  lin3 = off;
;ISd0 = low;
;ISd1 = low;
;ISd2 = low;
;ISd3 = low;
;
		}
	}
	public StateLin3Off18 Lin3Off11 = new StateLin3Off18("Lin3Off", this, false );
	public class StateLin3Med19 extends State {
			public StateLin3Med19( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  lin3 = med;
;ISd0 = high;
;ISd1 = med;
;ISd2 = low1;
;ISd3 = low;
;
		}
	}
	public StateLin3Med19 Lin3Med12 = new StateLin3Med19("Lin3Med", this, false );
	public class StateWait20 extends State {
			public StateWait20( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	}
	public StateWait20 Wait13 = new StateWait20("Wait", this, false );
	public class StateIS121 extends State {
			public StateIS121( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  ISd0 = high;
;ISd1 = high;
;ISd2 = high;
;ISd3 = high;
;
		}
	}
	public StateIS121 IS114 = new StateIS121("IS1", this, false );
	public class StateIS222 extends State {
			public StateIS222( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  ISd0 = high;
;ISd1 = high;
;ISd2 = med;
;ISd3 = med;
;
		}
	}
	public StateIS222 IS215 = new StateIS222("IS2", this, false );
	public class Transition6 extends Transition { 
		public Transition6( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return a_ac == ablated;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers7 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition6 p5 = new Transition6( ACInit10, Lin3Off11, this, triggers7, 1);
	public class Transition9 extends Transition { 
		public Transition9( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return a_ac == formed;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers10 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition9 p8 = new Transition9( ACInit10, Lin3Med12, this, triggers10, 2);
	public class Transition12 extends Transition { 
		public Transition12( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers13 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition12 p11 = new Transition12( p2, ACInit10, this, triggers13, 1);
	public class Transition15 extends Transition { 
		public Transition15( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return a_lin15 == ko && lin15 == 16;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers16 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition15 p14 = new Transition15( Wait13, IS114, this, triggers16, 1);
	public class Transition18 extends Transition { 
		public Transition18( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return a_lin15 == rf && lin15 == 16;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers19 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition18 p17 = new Transition18( Wait13, IS215, this, triggers19, 2);
	public class Transition21 extends Transition { 
		public Transition21( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers22 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition21 p20 = new Transition21( Lin3Off11, Wait13, this, triggers22, 1);
	public class Transition24 extends Transition { 
		public Transition24( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers25 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition24 p23 = new Transition24( Lin3Med12, Wait13, this, triggers25, 1);
}
public RegionR17 r10 = new RegionR17( this, 0 );
	}
	public StateAC16 AC9 = new StateAC16("AC", this, false );
	Transition p27 = new Transition(p26, AC9, this, new Event(""));
}
public RegionR18 r9 = new RegionR18( this, 1 );
	public class RegionR20 extends Region { 
	public RegionR20(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p43 = new Pseudostate(this, Kind.INITIAL);
	public class StateLIN1523 extends State {
			public StateLIN1523( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR19 extends Region { 
	public RegionR19(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p1 = new Pseudostate(this, Kind.INITIAL);
	public class StateLin15On24 extends State {
			public StateLin15On24( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  lin15 = on;
;
		}
	}
	public StateLin15On24 Lin15On5 = new StateLin15On24("Lin15On", this, false );
	public class StateLin15T25 extends State {
			public StateLin15T25( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	}
	public StateLin15T25 Lin15T6 = new StateLin15T25("Lin15T", this, false );
	public class StateLin15Init26 extends State {
			public StateLin15Init26( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	}
	public StateLin15Init26 Lin15Init7 = new StateLin15Init26("Lin15Init", this, false );
	public class StateLin15Off27 extends State {
			public StateLin15Off27( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  lin15 = off;
;
		}
	}
	public StateLin15Off27 Lin15Off8 = new StateLin15Off27("Lin15Off", this, false );
	public class Transition29 extends Transition { 
		public Transition29( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return a_lin15 == wt;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers30 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition29 p28 = new Transition29( Lin15Init7, Lin15On5, this, triggers30, 2);
	public class Transition32 extends Transition { 
		public Transition32( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			++lin15;
;
		}
	}
	ArrayList<Event> triggers33 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition32 p31 = new Transition32( Lin15Off8, Lin15T6, this, triggers33, 1);
	public class Transition35 extends Transition { 
		public Transition35( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return lin15 < 16;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			++lin15;
;
		}
	}
	ArrayList<Event> triggers36 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition35 p34 = new Transition35( Lin15T6, Lin15T6, this, triggers36, 1);
	public class Transition38 extends Transition { 
		public Transition38( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers39 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition38 p37 = new Transition38( p1, Lin15Init7, this, triggers39, 1);
	public class Transition41 extends Transition { 
		public Transition41( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return a_lin15 == ko || a_lin15 == rf;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers42 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition41 p40 = new Transition41( Lin15Init7, Lin15Off8, this, triggers42, 1);
}
public RegionR19 r4 = new RegionR19( this, 0 );
	}
	public StateLIN1523 LIN154 = new StateLIN1523("LIN15", this, false );
	Transition p44 = new Transition(p43, LIN154, this, new Event(""));
}
public RegionR20 r3 = new RegionR20( this, 2 );
	}
	public STATE_T AnchorCell3 = new STATE_T("AnchorCell", this, false );
	Transition p4 = new Transition(p3, AnchorCell3, this, new Event(""));
}
public REGION_T r1 = new REGION_T( sm, 0 );
	public void initializeTransitions() {
	}
}
